package Items.Market;

import java.util.Scanner;

public class Test {
    public static void main(String[] args) {
        Scanner in=new Scanner(System.in);
        Vip vip=new Vip();
        System.out.println("*************************");
        System.out.println("欢迎使用家乐福商城会员管理系统");
        System.out.println("*************************");
        Market market=new Market();
        market.showMarket();
        while (true){
            System.out.println("1.积分累加\t2.积分兑换\t3.查询剩余积分\t4.修改密码\t5.开卡\t6.退出");
            int choice=in.nextInt();
            if (choice==1){
                System.out.println("请输入会员卡号:");
                int vipNum=in.nextInt();
                System.out.println("请输入会员密码:");
                String vipPwd=in.next();
                System.out.println("请输入本次累加的积分：");
                int score=in.nextInt();
                System.out.println(market.addIntegral(vipNum,vipPwd,score)?"累加成功":"累加失败");
            }else if (choice==2){
                System.out.println("请输入卡号：");
                int num=in.nextInt();
                System.out.println("请输入密码：");
                String pwd=in.next();
                if (num==vip.getVipNum()&&pwd.equals(vip.getPwd())){
                    System.out.println("登录成功");
                    market.exchange(num,pwd);
                }else{
                    System.out.println("卡号或者密码不正确");
                }
            }else if (choice==3){
                System.out.println("请输入会员卡号：");
                int vipNum=in.nextInt();
                System.out.println("请输入密码：");
                String vipPwd=in.next();
                System.out.println(market.checkIntegral(vipNum,vipPwd)?"登录":"密码错误");
            }else if (choice==4){
                System.out.println("请输入卡号：");
                int num=in.nextInt();
                System.out.println("请输入密码：");
                String pwd=in.next();
                if (num==vip.getVipNum()&&pwd.equals(vip.getPwd())){
                    System.out.println("请输入新密码：");
                    String newPwd=in.next();
                    market.modify(num,pwd,newPwd);
                }else{
                    System.out.println("卡号或密码错误");
                }
            }else if (choice==5){
                System.out.println("请输入姓名：");
                vip.setName(in.next());
                System.out.println("请创建密码：");
                String pwd=in.next();
                String s1=pwd;
                char[] c=s1.toCharArray();
                if (c.length<6){
                    System.out.println("密码格式不正确,至少六个字符,请重新输入:");
                    pwd=in.next();
                }
                vip.setPwd(pwd);
                System.out.println("请输入联系电话：");
                vip.setPhone(in.next());
                market.addVip(vip);
            }else if (choice==6){
                System.out.println("谢谢使用，程序结束");
                System.exit(0);
            }
        }
    }
}
